package io.renren.sf.controller;

import java.util.Arrays;
import java.util.Map;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.sf.entity.CbStandardBrushEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.sf.entity.CbBasisStrokesEntity;
import io.renren.sf.service.CbBasisStrokesService;
import io.renren.common.utils.R;
import springfox.documentation.annotations.ApiIgnore;


/**
 * 
 *
 * @author cyl_txw
 * @email cyl_txw@gmail.com
 * @date 2021-04-26 16:00:55
 */
@RestController
@RequestMapping("sf/cbbasisstrokes")
@Api(tags = "基本笔画")
@ApiIgnore
public class CbBasisStrokesController {
    @Autowired
    private CbBasisStrokesService cbBasisStrokesService;

    @ApiOperation("获取基本笔画列表")
    @GetMapping("/getJbbhList")
    public R getJbbhList(@RequestParam Map<String, Object> params){
        long page = Long.parseLong((String) params.get("page"));
        long limit = Long.parseLong((String) params.get("limit"));
        Page<CbBasisStrokesEntity> jbbhPage = new Page<>(page, limit);
        cbBasisStrokesService.page(jbbhPage);
        return R.ok().put("jbbhPage", jbbhPage);
    }

    /**
     * 信息
     */
    @ApiOperation("获取基本笔画信息")
    //@RequiresPermissions("sf:cbbasisstrokes:info")
    public R info(@PathVariable("id") Long id){
		CbBasisStrokesEntity cbBasisStrokes = cbBasisStrokesService.getById(id);

        return R.ok().put("cbBasisStrokes", cbBasisStrokes);
    }

    /**
     * 保存
     */
    @ApiOperation("保存")
    @PostMapping("/save")
    //@RequiresPermissions("sf:cbbasisstrokes:save")
    public R save(@RequestBody CbBasisStrokesEntity cbBasisStrokes){
		cbBasisStrokesService.save(cbBasisStrokes);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation("修改")
    @PostMapping("/update")
    //@RequiresPermissions("sf:cbbasisstrokes:update")
    public R update(@RequestBody CbBasisStrokesEntity cbBasisStrokes){
		cbBasisStrokesService.updateById(cbBasisStrokes);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation("删除")
    @PostMapping("/delete")
    //@RequiresPermissions("sf:cbbasisstrokes:delete")
    public R delete(@RequestBody Long[] ids){
		cbBasisStrokesService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
